<!DOCTYPE html>
<!-- saved from url=(0052)http://getbootstrap.com/docs/4.0/examples/dashboard/ -->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>科院酒店预订管理系统</title>
    <!-- Bootstrap core CSS -->
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
    <!-- <link href="static/bootstrap/css/bootstrap.min.css" rel="stylesheet"> -->
    <!-- Custom styles for this template -->
    <link th:href="@{/css/dashboard.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/css/pagination.css}">

</head>

<body>

<div th:insert="~{admin/commons/commons::nav}"></div>

<div class="container-fluid">
    <div class="row">

        <!--传递参数给组件-->
        <div th:insert="~{admin/commons/commons::sidebar}"></div>

        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">

            <h1 style="margin-bottom: 20px">用户管理</h1>

            <div class="input-group input-group-sm" style="border: 1px solid black; padding:10px;margin-bottom: 10px">
                <form th:action="@{/selectUser}">
                    用户名： <input
                        style="height: 30px;width:100px;margin-bottom: 10px; margin-left: 15px;margin-right: 15px; padding-left: 5px;   "
                        type="text" name="username" class="btn-control" placeholder="username"
                        aria-describedby="sizing-addon3">
                    所属角色：
                    <select style="height: 30px;width:100px;margin-bottom: 10px; margin-left: 15px;margin-right: 15px; padding-left: 5px;   ">
                        <option th:each="role:${roles}" th:value="${role.getName()}"
                                th:text="${role.getName()==1?'超级管理员':'普通用户'}"></option>
                    </select>
                    性别： <select
                        style="height: 30px;width:100px;margin-bottom: 10px; margin-left: 15px;margin-right: 15px; padding-left: 5px;   ">
                    <option>全部</option>
                    <option>男</option>
                    <option>女</option>
                </select>
                    <button type="submit"  class="btn btn-sm btn-success"
                            style="text-align: center; height: 30px;width:100px;margin-bottom: 10px; margin-left: 15px;margin-right: 15px; padding-left: 5px; padding-bottom: 5px;">
                        搜索
                    </button>
                    <a th:href="@{/skip/addUserPage}" class="btn btn-sm btn-success"
                       style="text-align: center; height: 30px;width:100px;margin-bottom: 10px; margin-left: 15px;margin-right: 15px; padding-left: 5px; padding-bottom: 10px;">添加用户</a>
                </form>
            </div>

            <div class="table-responsive" style="border: 1px solid black;padding: 10px">
                <h4 style="background-color: ghostwhite">用户信息列表</h4>
                <table class="table table-striped table-sm">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>姓名</th>
                        <th>权限</th>
                        <th>性别</th>
                        <th>电话号码</th>
                        <th>年龄</th>
                        <th>地址</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="emp:${emps}">
                        <td th:text="${emp.getId()}"></td>
                        <td th:text="${emp.getUsername()}"></td>
                        <td th:text="${emp.getRoleId()==1?'超级管理员':'管理员'}"></td>
                        <td th:text="${emp.getSex()==1?'男':'女'}"></td>
                        <td th:text="${emp.getPhone()}"></td>
                        <td th:text="${emp.getAge()}"></td>
                        <td th:text="${emp.getAddress()}"></td>
                        <td>
                            <a class="btn btn-sm btn-primary" th:href="@{'/emp/'+${emp.getId()}}">修改</a>
                            <button id="buttonid" class="btn btn-sm btn-danger"
                                     th:href="@{'/deleted/' + ${emp.getId()}}" >删除
                            </button>
                            <!-- th:href="@{'/deleted/'+${emp.getId()}}"-->
                        </td>
                    </tr>
                    </tbody>
                </table>
                <div class="box">
                    <div id="pagination" class="page center"></div>
                </div>
            </div>
        </main>
    </div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript" th:src="@{/js/jquery-3.2.1.slim.min.js}"></script>
<script type="text/javascript" th:src="@{/js/popper.min.js}"></script>
<script type="text/javascript" th:src="@{/js/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/js/jquery.pagination.js}"></script>
<!-- Icons -->
<script type="text/javascript" th:src="@{/js/feather.min.js}"></script>
<script type="text/javascript">
        //删除
        function del(id) {
            if (confirm("确实要删除吗?")) {
                // alert(id);
                $.ajax({
                    type: "post",
                    url: '/deleted/'+id,
                    success: function (data) {
                        alert("删除成功");
                    },
                    error: function (data) {
                        alert("删除失败");
                    }
                });
                alert("已经删除！");
            } else {
                alert("已经取消了删除操作");
            }
        };
</script>
<script type="text/javascript">
    var pageNum = [[${pageInfo.pageNum}]];
    var pages = [[${pageInfo.pages}]];
    var pageSize = [[${pageInfo.pageSize}]];
    //
    $("#pagination").pagination({
        currentPage: pageNum,
        totalPage: pages,
        isShow: true,
        count: pageSize,
        homePageText: "首页",
        endPageText: "尾页",
        prevPageText: "上一页",
        nextPageText: "下一页",
    });
    //点击页数
    $('.ui-pagination-page-item').on('click', function () {
        var pageNum = $(this).attr('data-current');
        var zhanghao = $("#searchrole").val();   //这是搜索时的参数，根据实际情况加或者不要

        window.location.href = encodeURI('/sys/role/index?pageNum=' + pageNum+'&username='+zhanghao);
    });
</script>
</body>
</html>